<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns="http://www.w3.org/1999/xhtml">



    <ui:define name="content">
        <h:panelGroup rendered="#{!webUserController.hasPrivilege('LabBilling')}" >
            You are NOT authorized
        </h:panelGroup>

        <h:panelGroup rendered="#{webUserController.hasPrivilege('LabBilling')}" styleClass="opdPanel" >
            <h:form id="form">
                <p:focus id="focusIx" for="acIx" />
                <h:panelGroup rendered="#{!billController.printPreview}" styleClass="alignTop" >
                    <p:panel style="min-height: 600px; position:relative;"  >
                        <f:facet name="header" >
                            <h:panelGrid columns="10"  >
                                <h:outputLabel value="OPD Bill" />
                                <h:outputLabel value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" style="min-width: 50px;" />
                                <p:selectOneMenu   id="cmbPs" value="#{billController.paymentScheme}">
                                    <!--<f:selectItem itemLabel="Select Payment Method" />-->                                    
                                    <f:selectItems value="#{paymentSchemeController.items}" var="paysch" itemLabel="#{paysch.name}" itemValue="#{paysch}"  />
                                    <p:ajax process="cmbPs" update="pBillDetails tblBillItem lblCardRef txtCardRef lblCheqRef txtCheqRef bank" event="change" />
                                    
                                </p:selectOneMenu>
                                <h:outputLabel id="lblCardRef" value="Card Ref. No" style="display: #{billController.paymentMethod ne 'Card' ? 'none' : 'block'} ; " />
                                <p:inputText autocomplete="off"  id="txtCardRef" value="#{billController.creditCardRefNo}" style="display: #{billController.paymentMethod ne 'Card' ? 'none' : 'block'} ; " />
                                <h:outputLabel id="lblCheqRef" value="Cheque No" style="display: #{billController.paymentMethod ne 'Cheque' ? 'none' : 'block'} ; " />
                                <p:inputText autocomplete="off"  id="txtCheqRef" value="#{billController.chequeRefNo}" style="display: #{billController.paymentMethod ne 'Cheque' ? 'none' : 'block'} ; " />
                                <h:selectOneMenu id="bank" value="#{billController.chequeBank}" style="display: #{billController.paymentMethod ne 'Cheque' ? 'none' : 'block'} ; ">
                                    <f:selectItem itemLabel="Select Bank"/>
                                    <f:selectItems value="#{institutionController.banks}" var="inst" itemLabel="#{inst.name}" itemValue="#{inst}"/>
                                </h:selectOneMenu>
                                <p:commandButton  value="Settle" action="#{billController.settleBill}" ajax="false"  style="width: 150px; padding: 1px;border: 1px solid ; margin: auto;">
                                </p:commandButton>
                                <p:commandButton value="New Lab Bill" ajax="false" action="#{billController.prepareNewBill()}" >
                                </p:commandButton>
                            </h:panelGrid>
                        </f:facet>

                        <h:panelGrid columns="2" >

                            <h:panelGrid columns="1" >

                                <h:panelGroup id="panelPatient" >

                                    <p:tabView id="tvPt" style="min-height: 250px;"  >
                                        <p:ajax event="tabChange"  process="@this" listener="#{billController.onTabChange}" />

                                        <p:tab id="tabNewPt" title="New Patient"  >
                                            <h:panelGrid columns="2" >
                                                <h:outputLabel value="Title"/>
                                                <p:selectOneMenu  id="cmbTitle" value="#{billController.newPatient.person.title}"  >
                                                    <f:selectItem itemLabel="Mr." itemValue="Mr"/>
                                                    <f:selectItem itemLabel="Mrs." itemValue="Mrs"/>
                                                    <f:selectItem itemLabel="Miss." itemValue="Miss"/>
                                                    <f:selectItem itemLabel="Ms." itemValue="Ms"/>
                                                    <f:selectItem itemLabel="Master." itemValue="Master"/>
                                                    <f:selectItem itemLabel="Baby" itemValue="Baby"/>
                                                    <f:selectItem itemLabel="Rev." itemValue="Rev"/>
                                                    <f:selectItem itemLabel="Rt.Rev" itemValue="RtRev"/>
                                                    <f:selectItem itemLabel="Hon" itemValue="Hon"/>
                                                    <f:selectItem itemLabel="Rt.Hon" itemValue="RtHon"/>
                                                    <f:selectItem itemLabel="Dr." itemValue="Dr"/>
                                                    <f:selectItem itemLabel="Dr.(Mrs)" itemValue="DrMrs"/>
                                                    <f:selectItem itemLabel="Dr.(Ms.)" itemValue="DrMs"/>
                                                    <f:selectItem itemLabel="Dr.(Miss)" itemValue="DrMiss"/>
                                                    <f:selectItem itemLabel="Prof." itemValue="Prof"/>
                                                    <f:selectItem itemLabel="Other" itemValue="Other"/>
                                                </p:selectOneMenu>
                                                <h:outputLabel value="Name"/>
                                                <p:inputText autocomplete="off"  id="txtNewPtName" value="#{billController.newPatient.person.name}" style="width: 200px;text-transform:capitalize;">
                                                </p:inputText>
                                                <h:outputLabel value="Sex"/>
                                                <p:selectOneMenu id="txtNewSex"  value="#{billController.newPatient.person.sex}" style="width: 200px;">
                                                    <f:selectItem itemLabel="Select Sex"/>
                                                    <f:selectItem itemLabel="Male" itemValue="Male"/>
                                                    <f:selectItem itemLabel="Female" itemValue="Female"/>
                                                    <f:selectItem itemLabel="Unknown" itemValue="Unknown"/>
                                                    <f:selectItem itemLabel="Other" itemValue="Other"/>
                                                </p:selectOneMenu>
                                                <h:outputLabel value="Age"/>
                                                <p:inputText autocomplete="off"  id="txtNewPtAge"  value="#{billController.ageText}">
                                                    <f:ajax event="keyup" execute="txtNewPtAge" render="calNewPtDob"  />
                                                </p:inputText>

                                                <h:outputLabel value="Address"/>
                                                <p:autoComplete id="acNewPtArea" converter="areaCon" completeMethod="#{areaController.completeArea}" var="pta" itemLabel="#{pta.name}" itemValue="#{pta}" forceSelection="true" value="#{billController.newPatient.person.area}" ></p:autoComplete>

                                                <h:outputLabel value="Phone"/>
                                                <p:inputMask mask="999-9999999" id="txtNewPtPhone" autocomplete="off" maxlength="11" value="#{billController.newPatient.person.phone}">
                                                </p:inputMask>
                                                <h:outputLabel value="Date of Birth"/>
                                                <p:calendar  value="#{billController.newPatient.person.dob}" id="calNewPtDob"  navigator="true" pattern="dd/MM/yy" >
                                                    <f:ajax event="dateSelect" execute="@this" render="txtNewPtAge"/>
                                                </p:calendar>

                                                <p:watermark value="Please enter the name of the Patient" for="txtNewPtName" />
                                                <p:watermark value="Please enter the Age" for="txtNewPtAge" />
                                                <p:watermark value="Please enter the Phone" for="txtNewPtPhone" />
                                                <p:watermark value="Please enter the Date of Birth" for="calNewPtDob" />

                                            </h:panelGrid>
                                        </p:tab>
                                        <p:tab id="tabSearchPt" title="Search Patient">

                                            <h:panelGrid columns="1" >
                                                <p:autoComplete widgetVar="aPt" id="acPt" forceSelection="true" 
                                                                value="#{billController.searchedPatient}" 
                                                                completeMethod="#{patientController.completePatient}" 
                                                                var="apt" itemLabel="#{apt.person.name}" 
                                                                itemValue="#{apt}" size="30"  style="width: 400px;">
                                                    <p:ajax event="itemSelect" process="acPt" update="panSearch"/>
                                                </p:autoComplete>   

                                                <h:panelGrid id="panSearch" columns="2" >
                                                    <h:outputLabel  rendered="#{billController.searchedPatient!=null}" value="Name" />
                                                    <h:outputLabel rendered="#{billController.searchedPatient!=null}" value="#{billController.searchedPatient.person.name}" ></h:outputLabel>
                                                    <h:outputLabel  rendered="#{billController.searchedPatient!=null}" value="Sex" />
                                                    <h:outputLabel rendered="#{billController.searchedPatient!=null}" value="#{billController.searchedPatient.person.sex}" ></h:outputLabel>
                                                    <h:outputLabel  rendered="#{billController.searchedPatient!=null}" value="DOB"  />

                                                    <h:outputLabel rendered="#{billController.searchedPatient!=null}" value="#{billController.searchedPatient.person.dob}"   >
                                                        <f:convertDateTime pattern="dd/MM/yy" />
                                                    </h:outputLabel>

                                                    <h:outputLabel  rendered="#{billController.searchedPatient!=null}" value="Adress" />
                                                    <h:outputLabel rendered="#{billController.searchedPatient!=null}" value="#{billController.searchedPatient.person.address}" ></h:outputLabel>
                                                </h:panelGrid>
                                            </h:panelGrid>

                                        </p:tab>

                                    </p:tabView>

                                </h:panelGroup>

                                <h:panelGroup id="panelIx" >


                                    <p:panel id='pIxAdd' header="Items Requests" style="min-height: 350px;"  >
                                        <p:focus  context="acIx"/>
                                        <p:autoComplete widgetVar="aIx" id="acIx" forceSelection="true" value="#{billController.currentBillItem.item}" completeMethod="#{itemController.completeItemWithoutPackOwn}" var="ix" itemLabel="#{ix.name}" itemValue="#{ix}" size="30"  style="width: 400px;">
                                            <p:column>
                                                <h:outputLabel value="#{ix.name}"/>
                                            </p:column>
                                            <p:column>
                                                <h:outputLabel value="#{ix.total}"/>
                                            </p:column>

                                        </p:autoComplete>
                                        <h:commandButton id="btnAddIx" value="Add" action="#{billController.addToBill()}">
                                            <f:ajax execute="acIx btnAddIx" render="focusIx tblBillItem  pBillDetails pIxAdd" />
                                        </h:commandButton>
                                        <p:defaultCommand target="btnAddIx" />
                                    </p:panel>

                                </h:panelGroup>

                            </h:panelGrid>


                            <h:panelGrid columns="1" >

                                <p:dialog id="panDoc" header="Add New Doctor" widgetVar="dlg" resizable="false">  
                                    <h:panelGrid columns="2" style="margin-bottom:10px">  
                                        <h:outputText id="lblNameD" value="Name" ></h:outputText>
                                        <h:inputText autocomplete="off" id="txtNameD"  value="#{doctorController.current.person.name}"  ></h:inputText>
                                        <h:outputText id="lblPhoneD" value="Phone" ></h:outputText>
                                        <h:inputText autocomplete="off" id="txtPhoneD" value="#{doctorController.current.person.phone}"  ></h:inputText>
                                        <h:outputText id="lblFaxD" value="Fax" ></h:outputText>
                                        <h:inputText autocomplete="off" id="txtFaxD" value="#{doctorController.current.person.fax}"  ></h:inputText>
                                        <h:outputText id="lblMobileD" value="Mobile" ></h:outputText>
                                        <h:inputText autocomplete="off" id="txtMobileD" value="#{doctorController.current.person.mobile}"  ></h:inputText>
                                        <h:outputText id="lblAddressD" value="Address" ></h:outputText>
                                        <h:inputText autocomplete="off" id="txtAddressD" value="#{doctorController.current.person.address}"  ></h:inputText>
                                        <h:outputText value="Speciality" ></h:outputText>                                    
                                        <h:selectOneListbox id="cmbSpecialityD" size="1" value="#{doctorController.current.speciality}" >
                                            <f:selectItem itemLabel="Please select a speciality"/>
                                            <f:selectItems value="#{specialityController.items}" var="cat" itemLabel="#{cat.name}" itemValue="#{cat}" />
                                        </h:selectOneListbox>
                                        <h:outputText id="lblRegD" value="Registration" ></h:outputText>
                                        <h:inputText autocomplete="off" id="txtRegD" value="#{doctorController.current.registration}"  ></h:inputText>                 
                                        <h:outputText id="lblQuaD" value="Qualification" ></h:outputText>
                                        <h:inputText autocomplete="off" id="txtQuaD" value="#{doctorController.current.qualification}"  ></h:inputText>   

                                        <p:commandButton id="btnDocSave" value="Add New" process="btnDocSave panDoc" update="panDoc #{p:component('cmbDoc')}" actionListener="#{doctorController.saveSelected()}" styleClass="buttons" oncomplete="dlg.hide();">
                                        </p:commandButton>

                                    </h:panelGrid>  

                                </p:dialog>  


                                <h:panelGroup id="panelBillReferrals" >

                                    <p:tabView >
                                        <p:tab title="Refering Doctor">
                                            <p:autoComplete forceSelection="true" id="cmbDoc" value="#{billController.referredBy}" completeMethod="#{doctorController.completeDoctor}" var="ix" itemLabel="#{ix.person.name}" itemValue="#{ix}" size="30"  style="width: 400px;">
                                            </p:autoComplete>
                                            <p:commandButton id="btnAddNewDoc" type="button" value="Add New Doctor" onclick="dlg.show();" actionListener="#{doctorController.prepareAdd}" process="btnAddNewDoc" update="#{p:component('panDoc')}" />  
                                        </p:tab>
                                        <p:tab title="Company" >
                                            <p:autoComplete id="creditCom" forceSelection="true" value="#{billController.creditCompany}"  completeMethod="#{creditCompanyController.completeCredit}" var="ix" itemLabel="#{ix.name}" itemValue="#{ix}" size="30"  style="width: 400px;">

                                            </p:autoComplete>
                                            <h:commandButton actionListener="#{billController.calTotals()}" value="Set CreditCompay">
                                                <f:ajax execute="creditCom" render=":#{p:component('panelBillTotals')}  :#{p:component('tblRequests')} "/>
                                            </h:commandButton>
                                        </p:tab>                                       
                                        <p:tab title="Staff">
                                            <p:autoComplete forceSelection="true" converter="stfcon" value="#{billController.staff}" completeMethod="#{staffController.completeStaff}" var="ix2" itemLabel="#{ix2.person.name}" itemValue="#{ix2}" size="30"  style="width: 400px;">
                                            </p:autoComplete>
                                        </p:tab>

                                    </p:tabView>

                                </h:panelGroup>

                                <h:panelGroup id="panelBillItems" >

                                    <p:tabView id="tblBillItem" >
                                        <p:tab id="tabBillItems" title="Bill Items" >
                                            <p:dataTable id="tblRequests" rowIndexVar="rowIndex" value="#{billController.lstBillEntries}" var="bi" >

                                                <p:column>
                                                    <f:facet name="header">No</f:facet>
                                                        <h:outputLabel value="#{rowIndex+1}"/>
                                                </p:column>
                                                <p:column>
                                                    <f:facet name="header">Item</f:facet>
                                                        <h:outputLabel value="#{bi.billItem.item.name}"/>
                                                </p:column>
                                                <p:column>
                                                    <f:facet name="header">Fee</f:facet>
                                                        <h:outputLabel value="#{bi.billItem.netValue}"/>
                                                </p:column>
                                                <p:column>
                                                    <f:facet name="header">Department</f:facet>
                                                        <h:outputLabel value="#{bi.billItem.item.department.name}"/>
                                                </p:column>

                                                <p:column>
                                                    <h:commandButton id="btnRemove" value="X" action="#{billController.removeBillItem}" >
                                                        <f:setPropertyActionListener  value="#{rowIndex}" target="#{billController.index}" />
                                                        <p:ajax  process="btnRemove" update="@form" />
                                                    </h:commandButton>
                                                </p:column>
                                            </p:dataTable>
                                        </p:tab>
                                        <p:tab id="tabBillIx" title="Tests" >
                                            <p:dataTable rowIndexVar="rowIndex" value="#{billController.lstBillComponents}" var="bix" >
                                                <p:column>
                                                    <f:facet name="header">No</f:facet>
                                                        <h:outputLabel value="#{rowIndex+1}"/>
                                                </p:column>
                                                <p:column>
                                                    <f:facet name="header">Name</f:facet>
                                                        <h:outputLabel value="#{bix.item.name}"/>
                                                </p:column>

                                            </p:dataTable>
                                        </p:tab>
                                        <p:tab id="tabBillFee" title="Fees" >
                                            <p:dataTable rowIndexVar="rowIndex" value="#{billController.lstBillFees}" var="bif" >
                                                <p:column>
                                                    <f:facet name="header">No</f:facet>
                                                        <h:outputLabel value="#{rowIndex+1}"/>
                                                </p:column>
                                                <p:column>
                                                    <f:facet name="header">Fee</f:facet>
                                                    <h:inputText autocomplete="off" id="txtFeeVal" value="#{bif.feeValue}" disabled="#{!bif.billItem.item.userChangable}" >
                                                        <f:ajax event="keyup" execute="txtFeeVal" render=" :#{p:component('tblRequests')}  :#{p:component('pBillDetails')}" listener="#{billController.feeChanged}" />
                                                    </h:inputText>
                                                </p:column>

                                                <p:column>
                                                    <f:facet name="header">Payee</f:facet>
                                                    <h:outputLabel value="#{bif.institution.name}" rendered="#{bif.institution!=null}" ></h:outputLabel>
                                                    <h:outputLabel value="#{bif.department.name}" rendered="#{bif.department!=null}" ></h:outputLabel>
                                                    <h:outputLabel value="#{bif.staff.person.name}" rendered="#{bif.staff!=null}" ></h:outputLabel>
                                                </p:column>
                                            </p:dataTable>
                                        </p:tab>
                                    </p:tabView>



                                </h:panelGroup>

                                <h:panelGroup id="panelBillTotals" >

                                    <p:panel header="Bill Details" id="pBillDetails" style="padding: 5px; margin: 10px;" >
                                        <p:panelGrid columns="2" columnClasses="numberCol, textCol"  >
                                            <h:outputLabel value="Total" ></h:outputLabel>
                                            <h:outputLabel id="tot" value="#{billController.total}" >
                                                <f:convertNumber pattern="#,##0.00" />
                                            </h:outputLabel>
                                            <h:outputLabel value="Discount" ></h:outputLabel>
                                            <h:outputLabel id="dis" value="#{billController.discount}" ></h:outputLabel>
                                            <h:outputLabel value="Net Total" ></h:outputLabel>
                                            <h:outputLabel id="netTotal" value="#{billController.netTotal}" ></h:outputLabel>
                                            <h:outputLabel value="Tendered" ></h:outputLabel>
                                            <h:inputText autocomplete="off" id="paid" value="#{billController.cashPaid}" >
                                                <p:ajax process="netTotal paid" update="balance" event="keyup"/>
                                            </h:inputText>
                                            <h:outputLabel  value="Balance " ></h:outputLabel>
                                            <h:outputLabel id="balance" value="#{billController.cashBalance}" ></h:outputLabel>
                                        </p:panelGrid>

                                    </p:panel>
                                </h:panelGroup>




                            </h:panelGrid>


                        </h:panelGrid>
                    </p:panel>
                </h:panelGroup>
                <h:panelGroup rendered="#{billController.printPreview}" >
                
                    <div >
                        
                        <div >
                            <div >
                                <p:commandButton value="Print" ajax="false" action="#" >
                                    <p:printer target="gpBillPreview" ></p:printer>
                                </p:commandButton>
                                <p:commandButton value="New Lab Bill" ajax="false" action="#{billController.prepareNewBill()}" >
                                </p:commandButton>
                                <div style="border: 1px solid;" >
    
                                    <p:panel   id="gpBillPreview"  style="margin: auto; border: 0px; padding: 0px; " >

                                        <div >
                                            <div>
                                                <ui:repeat value="#{billController.bills}" var="bill" >

                                                    <div style="page-break-after: always; page-break-inside: avoid; min-width: 5cm; min-height: 5cm;">
                                                        <div style="height:13.5cm!important; width:12cm!important; padding:0.0cm; overflow:hidden!important; page-break-after:always; font-family: sans-serif; font-size: 11px!important; position: relative;  margin: 0px; background-size: 100% auto; " >

                                                            <h:outputLabel value="#{bill.insId}"
                                                                           style="position:absolute;left:4.5cm; top:1.1cm;"  >
                                                            </h:outputLabel>

                                                            <h:outputLabel value="#{bill.billDate}"
                                                                           style="position: absolute; left: 9.8cm; top:1.1cm;" >
                                                                <f:convertDateTime pattern="dd/MM/yy"/>
                                                            </h:outputLabel>

                                                            <h:outputLabel value="#{bill.paymentScheme.name}"
                                                                           style="position:absolute;left:4.5cm; top:1.6cm;"  >
                                                            </h:outputLabel>

                                                            <h:outputLabel value="#{bill.billTime}"
                                                                           style="position: absolute; left: 9.8cm; top:1.6cm;" >
                                                                <f:convertDateTime pattern="hh mm a"/>
                                                            </h:outputLabel>

                                                            <h:outputLabel value="#{bill.patient.person.nameWithTitle}"
                                                                           style="position:absolute;left:4.5cm; top:2.0cm; text-transform: capitalize; "  >
                                                            </h:outputLabel>

                                                            <h:outputLabel value="#{bill.patient.person.phone}"
                                                                           style="position: absolute;left:4.5cm; top:2.5cm;"  >
                                                            </h:outputLabel>

                                                            <h:outputLabel value="Cashier : #{bill.creater.code}"
                                                                           style="position:absolute;left:2.0cm; top:12.0cm;"  >
                                                            </h:outputLabel>

                                                            <h:outputLabel value="#{bill.collectingCentre.name} #{bill.creditCompany.name}"
                                                                           style="position:absolute;left:5.5cm; top:12.0cm;"  >
                                                            </h:outputLabel>

                                                            <h:dataTable value="#{billController.lstBillEntries}" var="bip" style="position: absolute;left:1.6cm; top:3.5cm; border: 0px; "   >
                                                                <h:column >
                                                                    <h:outputLabel rendered="#{bip.billItem.bill.id eq bill.id}" value="#{bip.billItem.item.printName}" style="margin: 4px; font-size: 11px!important;" >
                                                                    </h:outputLabel>
                                                                </h:column>
                                                            </h:dataTable>

                                                            <div style="position: absolute;left:9.6cm; top:3.5cm; border: 0px; text-align: right!important;"  >
                                                                <h:dataTable value="#{billController.lstBillEntries}" var="bip1"  >
                                                                    <h:column >
                                                                        <h:outputLabel  rendered="#{bip1.billItem.bill.id eq bill.id}"  value="#{bip1.billItem.grossValue}"  style="margin: 4px; font-size: 11px!important;" >
                                                                            <f:convertNumber pattern="#,##0.00" />
                                                                        </h:outputLabel>
                                                                    </h:column>
                                                                </h:dataTable>
                                                            </div>
                                                            <div style="position: relative;left:3.6cm; margin-top: 0.5cm; top:8.0cm; border: 0px; text-align: right!important;" >

                                                                <table>
                                                                    <tr>
                                                                        <td>
                                                                            <br/>
                                                                            <br/>
                                                                        </td>
                                                                        <td>
                                                                            <br/>
                                                                            <br/>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td style="min-width: 4.5cm;text-align: left;">
                                                                            <h:outputLabel value="Total" style="font-size: 90%;  text-align: right!important;  font-size: 11px!important;   "/>
                                                                        </td>
                                                                        <td style="text-align: right!important; ">
                                                                            <h:outputLabel value="#{bill.total}"  style="font-size: 110%; font-weight: bold ; text-align: right!important; font-size: 11px!important;    ">
                                                                                <f:convertNumber pattern="#,##0.00" />
                                                                            </h:outputLabel>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td style="min-width: 4.5cm;text-align: left;">
                                                                            <h:outputLabel  rendered="#{bill.discount ne 0.0}" style="font-size: 90%;  text-align: right!important;  font-size: 11px!important;   "  value="Discount"/>
                                                                        </td>
                                                                        <td style="text-align: right!important; ">
                                                                            <h:outputLabel rendered="#{bill.discount ne 0.0}"   value="#{bill.discount}"  style="font-size: 90%;  text-align: right!important;  font-size: 11px!important;   ">
                                                                                <f:convertNumber pattern="#,##0.00" />
                                                                            </h:outputLabel>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td style="min-width: 4.5cm;text-align: left;">
                                                                            <h:outputLabel value="Net Total" style="font-size: 90%;  text-align: right!important;  font-size: 11px!important;   "/>
                                                                        </td>
                                                                        <td style="text-align: right!important; ">
                                                                            <h:outputLabel value="#{bill.netTotal}"  style="font-size: 110%; font-weight: bold ; text-align: right!important; font-size: 11px!important;    ">
                                                                                <f:convertNumber pattern="#,##0.00" />
                                                                            </h:outputLabel>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>

                                                                        <td style="min-width: 3cm;text-align: left; font-size: 11px!important;  ">
                                                                            <h:outputLabel  rendered="#{bill.paymentMethod eq 'Cash'}" value="Tendered"/>
                                                                        </td>
                                                                        <td style="text-align: right!important; ">
                                                                            <h:outputLabel  rendered="#{bill.paymentMethod eq 'Cash'}"  value="#{bill.cashPaid}"  style="text-align: right!important; font-size: 11px!important;   ">
                                                                                <f:convertNumber pattern="#,##0.00" />
                                                                            </h:outputLabel>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td style="min-width: 3cm; text-align: left;">
                                                                            <h:outputLabel rendered="#{bill.paymentMethod eq 'Cash'}" value="Balance" style="text-align: right!important; font-size: 11px!important;   "/>
                                                                        </td>  
                                                                        <td style="text-align: right!important; ">
                                                                            <h:outputLabel  rendered="#{bill.paymentMethod eq 'Cash'}"  value="#{0 - bill.cashBalance}"  style="text-align: right!important; font-size: 11px!important;   ">
                                                                                <f:convertNumber pattern="#,##0.00" />
                                                                            </h:outputLabel>
                                                                        </td>
                                                                    </tr>

                                                                </table>

                                                            </div>


                                                        </div>

                                                    </div>

                                                </ui:repeat>
                                            </div>
                                        </div>

                                    </p:panel>
                                </div>
                            </div>
                        </div>
                    </div>
                </h:panelGroup>

            </h:form>
        </h:panelGroup>
    </ui:define>
</ui:composition>
